#include <sstream>

#include "SSLWrapper.hpp"
#include "ListenSocket.hpp"
#include "Logger.hpp"
#include "ConnectionHandlerHTTP.hpp"

int protected_main(int argc, char** argv) {
	ListenSocket socket = ListenSocket(IP("127.0.0.1"), 1234);
	while (true) {
		ConnectionHandler* newConn = new ConnectionHandlerHTTP();
		socket.handleConnection(newConn);
		Logger::log(Logger::INFO, "Host connected to server.");
	}
	return 0;
}

int main(int argc, char** argv) {
//	return protected_main(argc, argv);

	try {
		return protected_main(argc, argv);
	} catch (const GenericException& e) {
		e.terminate();
	}
	return 1;
}
